package think.net;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Client {
	public static void init() throws IOException {
		String s = null;
		BufferedReader into = new BufferedReader(new InputStreamReader(System.in));
		do {
			try (
					Socket soc = new Socket("127.0.0.1", 8989);
					BufferedReader in = new BufferedReader(new InputStreamReader(soc.getInputStream()));
					PrintWriter pw = new PrintWriter(soc.getOutputStream());
				) {

				s = into.readLine();
				System.out.println("输入:" + s);
				pw.println(s);
				pw.flush();
				System.out.println("返回:" + in.readLine());
				if ("over".equals(s)) {
					System.out.println("over - >>");
					break;
				}
			}
		} while (s != null && !"".equals(s.trim()));
	}

	public static void main(String[] args) throws IOException {
		Client.init();

	}
}
